package Adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.linefly.online_car.R;

import java.util.List;

import Been.been_licheng;

/**
 * Created by liheng on 2019/1/22.
 */

public class Adapter_licheng extends RecyclerView.Adapter<Adapter_licheng.ViewHolder>  {

private List<been_licheng> list1;
private item_click item_click;

public interface item_click{
    void itemclick(int position);
}
    public void setItemClick(Adapter_licheng.item_click itemClick){
        this.item_click = itemClick;
    }

    public Adapter_licheng(List<been_licheng> list) {
        this.list1 = list;
    }

class ViewHolder extends RecyclerView.ViewHolder {
    TextView textView_sb,textView_cp,textView_sj,textView_gl;

    ViewHolder(View itemView) {
        super(itemView);
        textView_sb = itemView.findViewById(R.id.shebei);
        textView_cp = itemView.findViewById(R.id.chepai);
        textView_sj = itemView.findViewById(R.id.shijian);
        textView_gl = itemView.findViewById(R.id.gongli);



    }
}



    @Override
    public Adapter_licheng.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_rc_licheng, parent, false);
        Adapter_licheng.ViewHolder viewHolder = new Adapter_licheng.ViewHolder(view);
        return viewHolder;
    }


    @Override
    public void onBindViewHolder(Adapter_licheng.ViewHolder holder, final int position) {

        holder.textView_sb.setText(list1.get(position).getShebei());
        holder.textView_cp.setText(list1.get(position).getChepai());
        holder.textView_sj.setText(list1.get(position).getShijian());
        holder.textView_gl.setText(list1.get(position).getGongli());






        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                item_click.itemclick(position);
            }
        });

    }

    @Override
    public int getItemCount() {
        return list1.size();
    }

    @Override
    public long getItemId(int position) {
        return position;
    }



}
